import request from "../request.js"

// 登陆
function doLogin(data){
	return request({
		url:'/lejuClient/login/doLogin',
		method:'post',
		data
	})
}

// 获取用户信息
function getMemberInfo(){
	return request({
		url:'/lejuClient/login/getMemberInfo'
	})
}

// 注册账号
function register(data){
	return request({
		url:'/lejuClient/member/register',
		method:'post',
		data
	})
}

// 更新用户信息
function updateMemberInfo(data){
	return request({
		url:'/lejuClient/member/updateMemberInfo',
		method:'post',
		data
	})
}

// 重置密码
function resetPassword(username){
	return request({
		url:`/lejuClient/member/resetPassword/${username}`,
		method:'post'
	})
}

// 查询地址列表
function findAllAddress(){
	return request({
		url:"/lejuClient/address/findAllAddress"
	})
}

// 添加收货地址
function addAddressInfo(data){
	return request({
		url:"/lejuClient/address/addAddressInfo",
		method:'post',
		data
	})
}

// 删除地址信息
function delAddressInfo(addressId){
	return request({
		url:`/lejuClient/address/delAddressInfo/${addressId}`,
		method:'delete'
	})
}

// 切换默认状态
function switchDefault(addressId,defaultStatus){
	return request({
		url:`/lejuClient/address/switchDefault/${addressId}/${defaultStatus}`,
		method:'post'
	})
}

// 更新收获地址
function updateAddressInfo(data){
	return request({
		url:'/lejuClient/address/updateAddressInfo',
		method:'post',
		data
	})
}

// 获取购物车列表
function findAllCartItem(){
	return request({
		url:'/lejuClient/cart/findAllCartItem'
	})
}

// 删除多个购物车
function delCartItems(data){
	return request({
		url:'/lejuClient/cart/delCartItems',
		method:'post',
		data
	})
}

export {
	doLogin,
	getMemberInfo,
	register,
	updateMemberInfo,
	resetPassword,
	findAllAddress,
	addAddressInfo,
	delAddressInfo,
	switchDefault,
	updateAddressInfo,
	findAllCartItem,
	delCartItems
}